﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="UITestingBaseClass.cs" company="">
// </copyright>
// <summary>
//   The ui testing base class.
// </summary>
// --------------------------------------------------------------------------------------------------------------------
namespace UITest.SeleniumTestProject
{
    using System.IO;

    using Microsoft.VisualStudio.TestTools.UITesting;
    using Microsoft.VisualStudio.TestTools.UnitTesting;

    using UITest.Selenium.SeleniumContext;
    using UITest.Selenium.WebDrivers;

    /// <summary>
    ///     The ui testing base class.
    /// </summary>
    [CodedUITest]
    [DeploymentItem("IEDriverServer.exe")]
    [DeploymentItem(@"Sample\TestHtmlPage.html")]
    public class UITestingBaseClass : SeleniumBasePageContext
    {
        #region Fields

        /// <summary>
        ///     The current directory.
        /// </summary>
        protected readonly string CurrentDirectory = Directory.GetCurrentDirectory();

        /// <summary>
        ///     The ui test html page.
        /// </summary>
        protected UITestHtmlPage UITestHtmlPage;

        #endregion

        #region Public Methods and Operators

        /// <summary>
        ///     The my test initialize.
        /// </summary>
        [TestInitialize]
        public void MyTestInitialize()
        {
            // Define a single Selenium Context Here
            SeleniumContextFactory.New(new IEProvider());
            this.UITestHtmlPage = new UITestHtmlPage(this.Selenium);
        }

        #endregion

        ////Use TestCleanup to run code after each test has run
        // [TestCleanup()]
        // public void MyTestCleanup()
        // {        
        // // To generate code for this test, select "Generate Code for Coded UI Test" from the shortcut menu and select one of the menu items.
        // }
        #region Methods

        /// <summary>
        ///     The launch testing page.
        /// </summary>
        protected void LaunchTestingPage()
        {
            this.Selenium.WebDriver.Navigate().GoToUrl(this.CurrentDirectory + "/TestHtmlPage.html");
        }

        #endregion
    }
}